#include "types.h"
#include "interrupt.h"
#include "console.h"
#include "sectors.h"
#include "mem.h"
#include "exec.h"

void exec(char* bin, uint seg)
{
	int i;
    uchar buf[EXEC_MAX_SIZE];
	i=0;
	while(i<EXEC_MAX_SIZE) 
		 buf[i++] =0;
	
/*	printString("START EXEC...\n");
//	printString("FILE TO EXEC : ");printString(bin);printString("\n");
//	printString("AT SEGMENT : 0x");printInt(seg,16);printString("\n");
	printString("READING PROG...\n");
*/
	readFile(bin,buf);
/*	printString("BUF FIRST 32 bytes : \n");
	printString("---------------------------------------\n");
	for(i=0;i<32;i++)
	{
		printInt(buf[i],16);
        printChar(' ');
	}
	printString("\n");
	printString("---------------------------------------\n");
	printString("COPYING BIN...\n");
*/
	for(i=0;i<EXEC_MAX_SIZE;i++)
	{
		memPutB(seg,i,buf[i]);
	}
//	printString("COPY DONE...\n");
//	printString("JUMPING...\n");
	jump(seg);
}
